import requests

url = "https://api.siliconflow.cn/v1/chat/completions"

# 定义记忆体变量，存储对话历史
context_list = []

payload = {
    "model": "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B",
    "stream": False,
    "max_tokens": 512,
    "temperature": 0.7,
    "top_p": 0.7,
    "top_k": 50,
    "frequency_penalty": 0.5,
    "n": 1,
    "stop": [],
    "messages": None,
}
headers = {
    "Authorization": "Bearer sk-pusgnznrckhdogxrchddbfzrypvljzjdydjogvnfbprehtkj",
    "Content-Type": "application/json"
}


while True:

    # 发送用户的问题
    user_input = input("请输入你的问题：")
    context_list.append({"role": "user", "content": user_input})
    payload['messages'] = context_list
    response = requests.request("POST", url, json=payload, headers=headers)

    # 解析响应内容
    json_test = response.json()
    text = json_test['choices'][0]['message']['content']
    print(text)
    context_list.append({"role": "assistant", "content": text})
    



